package cn.itsource.basic.controller;

import cn.itsource.basic.service.IVerificationCodeService;
import cn.itsource.basic.util.AxajResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/verification")
public class VerificationCodeController {


    @Autowired
    private IVerificationCodeService verificationCodeService;

    /**
     *  获取注册验证码
     * @param parm 手机号
     * @return
     */
    @PostMapping("/sendMobileCode")
    public AxajResult sendMobileCode(@RequestBody Map<String,String> parm){
        //
        try {
            verificationCodeService.sendMobileCode(parm.get("phone"));
            return new  AxajResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new AxajResult(false,e.getMessage());
        }
    }
    /**
     *  获取微信绑定验证码
     * @param parm 手机号
     * @return
     */
    @PostMapping("/sendBinderMobileCode")
    public AxajResult sendBinderMobileCode(@RequestBody Map<String,String> parm){
        //
        try {
            verificationCodeService.sendBinderMobileCode(parm.get("phone"));
            return new  AxajResult();
        } catch (Exception e) {
            e.printStackTrace();
            return new AxajResult(false,e.getMessage());
        }
    }
}
